<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  var buffer_size = 5*1024*1024;
  var buffer_index = 0;
  var video = null;
  var frag_mp4_buffer = new Uint8Array(buffer_size);

  websocket.onmessage = function(evt){
    var buffer = new Uint8Array(evt.data);
    if(buffer.length !=0){
      if((buffer_index + buffer.length) <= buffer_size){
        frag_mp4_buffer.set(buffer, buffer_index);
        buffer_index = buffer_index + buffer.length;
        if(sourceBuffer.updating == false){
          var appended = frag_mp4_buffer.slice(0,buffer_index);
          sourceBuffer.appendBuffer(appended);
          frag_mp4_buffer.fill(0);
          buffer_index = 0;
        }
      }
    }
  };
</script>
</body>
</html>
